#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>


using namespace std;

//nlog(n)
class Solution1 {
public:
    int minArray(vector<int>& numbers) {
        sort(numbers.begin(),numbers.end());
        return numbers[0];
    }
};
//n
class Solution2 {
public:
    int minArray(vector<int>& numbers) {
        int m=numbers[0];
        for(int i=0;i<numbers.size();i++){
            m=min(m,numbers[i]);
        }
        return m;
    }
};
//log(n)
class Solution {
public:
    int minArray(vector<int>& num) {
        int l=0,r=num.size()-1;
          while(l<r){
            int m=l+(r-l)/2;
            //cout << "l= "<<l << " m= "<< m <<" r= "<< r <<endl;
            if(num[m]>num[r]){
                l=m+1;
            }else if(num[m]<num[r]){
                r=m;
            }else{
                r=r-1;
            }
        }
        return num[l];
    }
};




int main(){

    vector<int> v={3,1,3};
    Solution s;
    cout << s.minArray(v)<<endl;


    return 0;
}